//
// Created by hsj on 2024-5-14.
//

#include "limits.h"// limits.cpp -- some integer limits
#include <iostream>
#include <climits>// use limits.h for older systems； climits是整型的限制，小数的限制是cfloat
int main(){
    using namespace std;
    int n_int = INT_MAX;// initialize n int to max int value
    short n_short = SHRT_MAX;// symbols defined in climits file
    long n_long = LONG_MAX;
    long long n_llong = LLONG_MAX;
    // sizeof operator yields size of type or of variable
    cout << "int is " << sizeof (int) << " bytes." << endl ;
    cout << "short is " << sizeof n_short << " bytes." << endl;
    cout << "long is " << sizeof n_long << " bytes." << endl;
    cout << "long long is " << sizeof n_llong << "bytes." << endl;
    cout << endl ;

    cout << "Maximum values:" << endl;
    cout<<"int: "<<n_int<<endl;
    cout<<"int: "<<n_int + 1 <<endl; //+1越过最大量程，变成最小的负值
    cout << "short: "<< n_short << endl ;
    cout << "long: "<< n_long << endl;
    cout << "long long: "<< n_llong << endl << endl;
    cout << "Minimum int value = "<< INT_MIN << endl;
    cout << "Bits per byte = "<< CHAR_BIT << endl;

    return 0;
}
